#ifndef CXSERVERCONNECTION_H_INCLUDED
#define CXSERVERCONNECTION_H_INCLUDED

/**
 *
 * \file CXServerConnection.h
 * \brief This file contains the CXServerConnection class declaration.
 * \author Vladimir Klubkov (aka marked)
 *
 * Last changes date:
 * \date 05.03.2011
 *
 * Copyright 2011 Vladimir Klubkov <marked-one@yandex.ru>
 *
 * This file is part of OOXlib.
 *
 * OOXLib is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * OOXlib is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with OOXlib; if not, you can try to find  it here:
 * http://www.gnu.org/licenses/gpl.txt
 * or write to the Free Software Foundation, Inc., 59 Temple Place,
 * Suite 330, Boston, MA  02111-1307  USA
 *
 */

#include "CException.h"

namespace OOXlib {

/**
 * \class CXServerConnection
 * This class handles the connection to the X Server.
 * It must be used to get the Display structure and some information from it instead of simply using the xlib fucntions.
 */
class CXServerConnection {
public:
    /**
     * \class CNULLXOpenDisplayException
     * Exception handler class.
     */
    class CNULLXOpenDisplayException : public CException {
    public:
        CNULLXOpenDisplayException(const ::std::string &File, const int iLine, const ::std::string &Function);
    };
    /**
     * \class CGetenvXOpenDisplayException
     * Exception handler class.
     */
    class CGetenvXOpenDisplayException : public CException {
    public:
        CGetenvXOpenDisplayException(const ::std::string &File, const int iLine, const ::std::string &Function);
    };
    /**
     * \class CXOpenDisplayException
     * Exception handler class.
     */
    class CXOpenDisplayException : public CException {
    public:
        CXOpenDisplayException(const ::std::string &File, const int iLine, const ::std::string &Function);
    };
public:
// Constructor.
    CXServerConnection();
    CXServerConnection(const ::std::string &DisplayName);
// Destructor.
    virtual ~CXServerConnection();
// Getters.
    virtual Display* Get() const;
    virtual operator Display*() const;
    virtual int GetScreensCount() const;
// Checkers.
    virtual bool IsScreenNumberValid(const int iScreenNumber) const;
// Server information.
    virtual ::std::string ServerName() const;
    virtual ::std::string ServerVendorName() const;
    virtual int ServerVendorRelease() const;
    virtual int ProtocolVersion() const;
    virtual int ProtocolRevision() const;
    virtual int ConnectionNumber() const;
protected:
    ::Display *m_pDisplay;
    int m_iScreensCount;
    int m_iDefaultScreenNumber;
};
/**
 * \class CNULLPtrConnectionException
 * Exception handler class.
 */
class CNULLPtrConnectionException : public CException {
public:
    CNULLPtrConnectionException(const ::std::string &File, const int iLine, const ::std::string &Function);
};

} // OOXlib

#endif // CXSERVERCONNECTION_H_INCLUDED
